import Vue from 'vue'
import Vuex from 'vuex'
import vuexPersist from 'vuex-persist'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    list: [
      {
        title: "123",
        status: 0
      },
      {
        title: "456",
        status: 0
      },
      {
        title: "789",
        status: 0
      },
      {
        title: "999",
        status: 0
      }
    ]
  },
  mutations: {
    yidu(state, item) {
      state.list.forEach((ele) => {
        if (item.title == ele.title) {
          ele.status = 1
        }
      })
    },
    hy(state, item) {
      state.list.forEach((ele) => {
        if (item.title == ele.title) {
          ele.status = 0
        }
      })
    },
    remove(state, item) {
      state.list.forEach((ele) => {
        if (item.title == ele.title) {
          ele.status = 2
        }
      })
    },
    weidu(state, item) {
      state.list.forEach((ele) => {
        if (item.title == ele.title) {
          ele.status = 0
        }
      })
    },
    qb(state) {
      state.list.forEach((item) => {
        if (item.status == 0) {
          item.status = 1
        }
      })
    },
    qb1(state) {
      state.list.forEach((item) => {
        if (item.status == 1) {
          item.status = 2
        }
      })
    },
    qb2(state) {
      state.list.forEach((item) => {
        if (item.status == 2) {
          item.status = 0
        }
      })
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [
    new vuexPersist({
      storage: window.localStorage,
    }).plugin
  ],
})
